HTML forms have special attributes that control how the form behaves when a user submits data.
These attributes are written inside the <form> tag.
The action attribute tells the browser where to send the form data after the user clicks the submit button.
Usually, the data is sent to a file on the server that processes the information.
In this example, when the user clicks Submit, the data is sent to process.php.
Important:If the action attribute is not written, the form data will be sent to the same page.
The target attribute decides where the response will be displayed after submitting the form.
Common Values:| Value | Meaning |
|---|---|
| _self | Opens in the same tab (default) |
| _blank | Opens in a new tab |
| _parent | Opens in the parent frame |
| _top | Opens in the full browser window |
| iframe name | Opens inside a specific iframe |
If you do not set the target, the result opens in the same tab.
The method attribute defines how the form data is sent to the server.
There are two main methods:Do NOT use GET for passwords or sensitive information because the data is visible in the URL.
Tip: Personal or sensitive information